#!/usr/bin/python
from flask import Flask, jsonify
from pymongo import MongoClient
import json

# import requests
app = Flask(__name__)
"""
tasks = [
    {
        'id': 1,
        'title': u'Buy groceries',
        'description': u'Milk, Cheese, Pizza, Fruit, Tylenol',
        'done': False
    },
    {
        'id': 2,
        'title': u'Learn Python',
        'description': u'Need to find a good Python tutorial on the web',
        'done': False
    }
]
"""
client = MongoClient()
## get dataname
# db = client.test
db = client.info

## get set
collection = db.api

lt = [0,1,2,3,4,5,6,7,9,10]
post = {"domain":lt[0],"ip":lt[1],"Registrar":lt[2],"Registration_Time":lt[3],"deadline":lt[4],"Sponsoring Registrar":lt[5],"Name Server":lt[6],"Domain status:":lt[7],"Registrar_Email":lt[8],"collection_time":lt[9]}
post1 = {"domain":lt[0],"ip":lt[1],"Registrar":lt[2],"Registration_Time":lt[3],"deadline":lt[4],"Sponsoring Registrar":lt[5],"Name Server":lt[6],"Domain status:":lt[7],"Registrar_Email":lt[8],"collection_time":lt[9]}
# tasks = [post,post1]
tasks =[]
tasks.append(post)
tasks.append(post1)
# for item in collection.find_one():
# for item in collection.find():
    # tasks.append(item)
    # tasks.append(json.dumps(item))

# print tasks[0]
# json.dumps(tasks)

@app.route('/todo/api/v1.0/tasks', methods=['GET'])
def get_tasks():
    return jsonify({'tasks': tasks})
    # return jsonify({'encode': encode})

if __name__ == '__main__':
    app.run(debug=True)
